home *** CD-ROM | disk | FTP | other *** search
- #include<hold/anim.h>
-
- /* 000 */ void insert_control(void);
- /* 001 */ void insertion(int [], int);
-
- /* 002 */ void insert_control(void){
- /* 003 */ int d[10] = {-1,10,9,8,7,6,5,4,3,2};
- /* 004 */ int parts = 10;
-
- a_func("insert_control",2);
- a_irayini(d,"d",parts,3);
- a_intini(parts,"parts",4);
- a_show(5);
- /* 005 */ insertion(d, parts);
- a_endfunc("insert_control",6);
- /* 006 */ }
-
- /* 007 */ void insertion(int a[], int n){
- /* 008 */ int i,j,t;
-
- a_func("insertion",7);
- a_iraypas("a",7);
- a_intini(n,"n",7);
- a_intini(i,"i",8);
- a_intini(j,"j",8);
- a_intini(t,"t",8);
- a_intass("i","1",9);
- a_intcomp("i < n",9);
-
- /* 009 */ for(i=1;i<n;i++){
- /* 010 */ t = a[i];
- a_intass("t","a[i]",10);
- /* 011 */ j = i;
- a_intass("j","i",11);
- a_intcomp("a[j-1] > t",12);
- /* 012 */ while(a[j-1]>t){
- /* 013 */ a[j] = a[j-1];
- a_intass("a[j]","a[j-1]",13);
- /* 014 */ j--;
- a_intass("j","j-1",14);
- /* 015 */ }
- /* 016 */ a[j]=t;
- a_intass("a[j]","t",16);
- a_intass("i","i+1",9);
- a_intcomp("i<n",9);
- /* 017 */ }
- a_endfunc("insertion",18);
- /* 018 */ }
-